/**
 * 将对象参数转换成字符串拼接在网址上
 * @param  {Object} param_obj {对象参数}
 * @return {string} {转换完成的字符串}
 */
export function paramJoin( param_obj ) {

    if ( ! param_obj ) return '';

    var filter_keys_arr = Object.keys( param_obj );

    return filter_keys_arr.reduce( function( before, current , index ) {

        var joint_symbol = filter_keys_arr.length - 1 - index  ? '&' : '' ;

        if ( param_obj[current] ) {
            if( Object.prototype.toString.call(param_obj[current]) === '[object Array]') {

                let current_str = '';

                param_obj[current].forEach(function(obj){
                    
                    current_str += current + '[]=' + obj + '&'

                })
                return before + current_str + joint_symbol;

            }else {

                return before + current + '=' + param_obj[current] + joint_symbol;
                
            }
        } else {
            return before;
        }

    }, '?' );
}